/********************************************************************************
* @File name: ultrasonic.h
* @Author: Loganx
* @Blog: https://www.cnblogs.com/loganxiang
* @Version: 1.0(2025-10-09)
* @Description: STC8A单片机超声波模块（IIC接口）测距
********************************************************************************
* 本软件使用了STC的STC8A官方库；
********************************************************************************/
#ifndef _LGX_ULTRASONIC
#define _LGX_ULTRASONIC

#include "lib/Config.h"
#include "lib/STC8A_GPIO.h"
#include "lib/STC8A_I2C.h"
#include "lib/STC8A_NVIC.h"
#include "lib/STC8A_Switch.h"

#define     ULTRASONIC_GPIO         GPIO_P3
#define     ULTRASONIC_PIN          GPIO_Pin_2|GPIO_Pin_3
#define     ULTRASONIC_SW           I2C_P33_P32

#define     ULTRASONIC_DEV_ADDR     0x57
#define     ULTRASONIC_CMD_ADDR     0xAE
#define     ULTRASONIC_DATA_ADDR    0xAF

extern uint32  Distance;

void UltrasonicInit(void);

void SystickCallbackUltrasonic(void);
uint32 GetDistance(void);

#endif